package com.scs.application.modules.msg.controller;

import com.scs.application.core.model.CommonResult;
import com.scs.application.core.mvc.controller.BaseController;
import com.scs.application.modules.msg.entity.MessageSend;
import com.scs.application.modules.msg.service.MessageSendService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 发送消息 controller
 *
 */
@AllArgsConstructor
@RestController
@RequestMapping("/msg/message_send")
public class MessageSendController extends BaseController {

    private final MessageSendService messageSendService;

    @PostMapping
    public CommonResult pushMessage(@RequestBody @Valid MessageSend entity) {
        boolean bSave = messageSendService.sendMessage(entity);
        return bSave ? CommonResult.ok("推送成功", entity) : CommonResult.error("推送失败");
    }

}
